/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.wx.mq.timerTask;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimerTask;
import org.apache.log4j.Logger;
import cn.ac.iie.di.wx.mq.common.RuntimeEnv;

/**
 *
 * @author Administrator
 */
public class CountTask extends TimerTask {

    static Logger logger = Logger.getLogger(CountTask.class.getName());
    private int cout = 0;

    public CountTask() {
    }

    @Override
    public void run() {
        Date date = new Date();
        SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");//设置日期格式
        String dfDate = df.format(date);
        if (dfDate.equals("23:59:59")) {
            logger.info("comsume: " + RuntimeEnv.CSCount.get()
                    + "\t" + "querygroupmedia: " + RuntimeEnv.GMCount.get()
                    + "\t" + "failNum: " + RuntimeEnv.FLCount.get());
            logger.info("init cout value");
            RuntimeEnv.CSCount.set(0);
            RuntimeEnv.GMCount.set(0);
            RuntimeEnv.FLCount.set(0);
        }
        //设置时间间隔
        int per = 59;
        if (cout < per) {
            ++cout;
        } else {
            logger.info("comsume: " + RuntimeEnv.CSCount.get()
                    + "\t" + "querygroupmedia: " + RuntimeEnv.GMCount.get()
                    + "\t" + "failNum: " + RuntimeEnv.FLCount.get());
            cout = 0;

        }
        //每1小时执行一次重发
    }

}
